Repository navigation
Conversation
… names A type can implement `Encrypt` and `Decrypt` by hand instead of deriving them. Such an impl names the sink traits, the `depth` constants, the types of a scalar, and the `Scalar` and `FromScalar` traits. `stack-encrypt` re-exported none of these, so a crate that wrote such an impl had to depend on `vitaminc-aead` too. The new `stack_encrypt::plaintext` module re-exports the sink traits and the scalar types. It also has a `depth` module of its own. That module adds `MAX_DEPTH` to the depth constants. `Scalar` and `FromScalar` are re-exported at the crate root, next to `Encrypt`, and `Decrypt`. The module docs show a complete hand-written `Encrypt` and `FromScalar` impl, run against the in-memory key source. The `OpaqueEncode` docs and doctests now import from `stack_encrypt`. The compile error for a `Scalar` type with the wrong `DEPTH` names `stack_encrypt::plaintext::depth::SCALAR`. A refused `FromScalar` bound now prints as `FromScalar`, through the root re-export, so one UI snapshot changes in that line only.
…pt's derives `stack_encrypt::Encrypt` and `stack_encrypt::Decrypt` re-exported the derives of vitaminc-aead-derive. Their code named every item through `::vitaminc_aead`. Rust resolves that path only in a crate that lists `vitaminc-aead` as a dependency of its own. So a crate that depended on `stack-encrypt` alone could not derive either trait. The error did not say why. The two derives now live in `stack-encrypt-derive`, in `src/value/`, and `stack-encrypt` re-exports them. The generated code names every item through `<crate>::__derive`. `<crate>` is `::stack_encrypt` unless `#[aead(crate = "...")]` names another path. `vitaminc_aead::__derive` is a hidden module that lists exactly the items the expansion names, and `stack_encrypt::__derive` re-exports it. No other part of vitaminc-aead is re-exported for the derives. vitaminc-aead-derive is removed rather than kept as a second public derive. So a derive bug has one place to fix, and one set of expansion tests. Its source, unit tests, and attribute docs move with their history. The moved files keep their MIT licence, in `LICENSE-MIT` beside them. vitaminc-aead loses its derive dependency and its re-export of the macros. Its own tests and doctests use Stack Encrypt's derive, with `#[aead(crate = "::vitaminc_aead")]`, since stack-encrypt depends on it. The attributes keep the name `aead`. That name does not name vitaminc. It also keeps them apart from the `#[stash(...)]` attributes of the record derives. So neither family of derives refuses the other's keys. The wire shape does not change. The UI snapshots change only in line numbers and in the depth error. That error now names `stack_encrypt::plaintext::depth::MAX_DEPTH`. These move with the crate: - the root workspace member and patch; - the mise task include, with a rustdoc task for stack-encrypt-derive in place of the old crate's; - the release-plz entry; - the mutation-testing config, now for the value derives only; - the workflow path filters and CODEOWNERS; - the vitaminc-aead supply-chain config. cargo deny now leaves stack-encrypt-derive out of vitaminc-aead's graph, as cargo vet's filter already did. The derive's own tests reach the whole workspace. BREAKING CHANGE: `vitaminc_aead::Encrypt` and `vitaminc_aead::Decrypt` are traits only. Import the derives from `stack_encrypt`. `#[aead(crate = "...")]` now names the path to `stack_encrypt`. A path to `vitaminc_aead` still works.
…paces Every Cargo workspace that resolves vitaminc-aead 0.10 patched both vitaminc-aead and vitaminc-aead-derive to the copies in this repository. The derive crate is gone, and vitaminc-aead no longer depends on it, so nothing in these workspaces resolves vitaminc-aead-derive 0.10 any more. A patch that names a missing path fails every cargo command in the workspace. These workspaces now patch vitaminc-aead alone: - the two Go guests; - recipher-js, and its test addon; - EQL, and its timing generator; - the three fuzz crates. Each `Cargo.lock` loses the vitaminc-aead-derive 0.10 entry. The 0.5.1 copy that cts-common reaches through vitaminc 0.5.1 still comes from crates.io. No code in these workspaces used the derives.
…ncrypt alone Every crate in this repository that derived `Encrypt` or `Decrypt` already depended on vitaminc-aead. So nothing noticed that the derives did not compile without it. The new crate is a member of the root workspace. Its only dependency is `stack-encrypt`, as an application's would be. `tests-crates.yml` builds and tests it with the rest. The crate derives both traits for these types: - a newtype; - a struct with named fields and a passthrough field; - a fieldless enum; - a generic newtype; - a generic struct. It also writes `Encrypt`, `Scalar`, and `FromScalar` by hand for one more type. Its tests send each type through `keyset.encrypt` or `keyset.encrypt_tree` and back, under the in-memory key source. `tests/manifest.rs` fails if the manifest names a dependency other than `stack-encrypt`. It also fails if any table names a vitaminc crate. Two trybuild cases pin what a user reads when a derive is refused. The trait bounds print as `stack_encrypt` paths. The depth error names `stack_encrypt::plaintext::depth::MAX_DEPTH`. The crate implements `Zeroize` by hand, through `stack_encrypt`'s re-export of the trait, so that it needs no zeroize dependency either. It is `publish = false`, with `release = false` in release-plz.toml. The live jobs of tests.yml skip a change that touches only this crate.
The stack-encrypt CHANGELOG has two new entries: - Under Fixed: the derives now compile in a crate that depends only on stack-encrypt. The entry says what stays the same, what `crate = "..."` now names, and how to migrate. - Under Added: the `plaintext` module, and the `Scalar` and `FromScalar` re-exports, for a hand-written impl. Two entries of the same release named `vitaminc_aead::plaintext::depth` and "Vitamin C's `Scalar`". They now name the stack-encrypt paths. The vitaminc-aead CHANGELOG lists two changes under Breaking. The crate has no derives of its own, and the entry says how to import them instead. The hidden `plaintext::__private` module is replaced by `__derive`. AGENTS.md's repository layout and SECURITY.md's package list name the two AEAD crates that remain. They say where the value derives went, and describe stack-encrypt-downstream.
…derives Brings in the latest review fixes of the base branch. Conflicts, and how they are resolved: - The derive's `encrypt.rs` moved to `packages/stack-encrypt-derive/src/value/encrypt.rs` here. The base branch decides once whether a type has a fixed depth. Its logic is kept as it is, with the generated paths renamed to `#aead::...` as in the rest of the moved file. - `vitaminc-aead-derive/src/lib.rs` is deleted here. Its new paragraph, that `#[derive(Zeroize)]` does not wipe a fieldless enum, moves to `stack-encrypt-derive/docs/value-derives.md`, with its doctest importing `stack_encrypt::Encrypt`. - `scalar.rs` keeps the base branch's new text and its wording of the `DEPTH` error, with the `stack_encrypt::plaintext::depth::SCALAR` path. - The stack-encrypt CHANGELOG keeps the base branch's entry, names `stack_encrypt::plaintext::depth`, and no longer says that a crate needs vitaminc-aead to use the derive. - The vitaminc-aead CHANGELOG has one Breaking section with the entries of both branches.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Mutation testing (cargo-mutants,
|
| caught | missed | unviable | timeout |
|---|---|---|---|
| 16 | 0 | 3 | 0 |
Every mutant in the changed lines was caught by a test.
coderdan
left a comment
There was a problem hiding this comment.
Code review at medium effort. Five findings: one pre-existing problem that this PR widens, and four nits. I checked each one against the branch. For the first, I also compared the registry copy of vitaminc-aead 0.10.0 with the copy in this repository.
| // The code that `#[derive(Encrypt)]` and `#[derive(Decrypt)]` write names | ||
| // each item through `::stack_encrypt::__derive`. Not an API. | ||
| #[doc(hidden)] | ||
| pub use vitaminc_aead::__derive; |
There was a problem hiding this comment.
Pre-existing, made one step wider: a published stack-encrypt cannot build against vitaminc-aead 0.10.0 from crates.io.
This line re-exports vitaminc_aead::__derive, which exists only in the copy in this repository. That copy is still at version 0.10.0, and the root Cargo.toml asks for 0.10.0 through a [patch]. Once cargo publish strips the path, the registry's 0.10.0 has no __derive, so the build fails with E0432.
This is not new. stack-encrypt on next already uses OwnedFrame and ValueKind, which crates.io's 0.10.0 does not have (I checked the registry source). What is new: this PR also removes vitaminc-aead's public Encrypt and Decrypt derives under the same version number, which is a breaking change in what looks like a patch release.
Fix: release planning, not code. vitaminc-aead needs a new version that marks the break (0.11.0), published from this repository before stack-encrypt. This is open question 1 in the description, for the maintainer.
There was a problem hiding this comment.
This one is for the maintainer, not a code change in this PR. It is open question 1 in the description: vitaminc-aead needs a new version that marks the break, published from this repository before stack-encrypt. The fixes for the other four findings are in progress.
There was a problem hiding this comment.
major The CHANGELOG makes the same claim: packages/stack-encrypt/CHANGELOG.md:1801 says "A path to vitaminc_aead still works" for #[aead(crate = …)]. That holds only against the patched in-tree copy, because the derive appends __derive and crates.io 0.10.0 has none. stack-encrypt 0.3.0 is not on crates.io and eql-pipeline-armed.mjs crates reports armed, so release-plz would try the publish once this reaches main. stack-encrypt-jsonpath and stack-encrypt-derive 0.3.0 do not depend on vitaminc-aead, so they could publish before stack-encrypt fails verification (not reproduced). A guard would catch it before release: run cargo publish --dry-run -p stack-encrypt on PRs, or make release-crates refuse while vitaminc-aead is release = false. Also qualify the CHANGELOG line.
Source: code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Agreed that this needs a guard, and it is already true on next, before this PR.
On next, release-plz.toml publishes stack-encrypt 0.3.0, and crates.io has only 0.1.0 and 0.2.0. stack-encrypt on next already uses OwnedFrame and ValueKind, which crates.io's vitaminc-aead 0.10.0 does not have. So a release from main would already fail at stack-encrypt, possibly after stack-encrypt-jsonpath and stack-encrypt-derive have published. This PR adds __derive to the same list.
Whether to add a guard, and which one, is for the maintainer. I've raised it. The CHANGELOG line is being qualified in this PR.
| @@ -1 +1 @@ | |||
| exclude(all(is_workspace_member(true),not(any(name(vitaminc-aead),name(recipher-frame),name(vitaminc-aead-derive))))) | |||
| exclude(all(is_workspace_member(true),not(any(name(vitaminc-aead),name(recipher-frame))))) | |||
There was a problem hiding this comment.
The derive code is no longer covered by cargo vet and cargo deny.
Before this PR, vitaminc-aead-derive and its dependencies (syn, quote, proc-macro2) were in this filter's checked set. The same code is now in stack-encrypt-derive, which this filter and deny.toml (exclude = ["stack-encrypt-derive"]) both leave out. supply-chain-vitaminc-aead.yml also no longer starts when that code changes, because its path filter does not list packages/stack-encrypt-derive/**.
So a change to the code that writes every derived Encrypt impl, or a bump of its syn dependency, is no longer vetted.
Fix: keep stack-encrypt-derive in the checked graph and in the workflow's path filter, or vet it in whichever workflow covers stack-encrypt's graph. The exclude was added because the derive's dev-dependencies pull in the whole workspace; excluding its dev-dependencies alone may be enough.
There was a problem hiding this comment.
Fixed in 01acb74, with a comment correction in 6e5cda5.
- The workflow now starts when
packages/stack-encrypt-derive/**changes. - cargo deny checks the derive as the root of its own graph, without its dev-dependencies (
--exclude-dev). That graph is 18 crates:syn,quote,proc-macro2,stack-encrypt-jsonpathand their dependencies. vitaminc-aead's and recipher-frame's checks are unchanged. - cargo vet requires the derive's normal dependencies at
safe-to-deploy, as it did forvitaminc-aead-derive. It puts no requirement on the derive's dev-dependencies, which reach the whole workspace.
Three additions for the maintainer to review:
- Two exemptions, for
thiserror1.0.69 andthiserror-impl1.0.69 atsafe-to-deploy, the same as the existing 2.0.18 entries. They come in throughstack-encrypt-jsonpath, and no imported registry audits them. No audits were written. - Two licence exceptions, for
stack-encrypt-deriveandstack-encrypt-jsonpathonly, by name. Their LICENSE file is the PolyForm Internal Use License, which cargo-deny 0.20.2 reads asPolyForm-Small-Business-1.0.0. I confirmed that withcargo deny list. - A policy on
stack-encrypt-jsonpaththat does not requiremiette.miettecomes only with jsonpath'sdiagnosticsfeature, which the derive does not turn on.
I ran the workflow's own commands with the pinned versions: deny passes for all three roots, and vet reports "Vetting Succeeded".
| let message = format!( | ||
| "`{name}` nests deeper than `MAX_DEPTH` levels, so the encrypting sink would refuse \ | ||
| its fully populated values" | ||
| "`{name}` nests deeper than `stack_encrypt::plaintext::depth::MAX_DEPTH` levels. Stack \ |
There was a problem hiding this comment.
Nit: the too-deep error always names stack_encrypt::plaintext::depth::MAX_DEPTH, even with #[aead(crate = "...")].
Every other path in the expansion follows the crate attribute, but this message is a fixed string. In vitaminc-aead's own tests and docs, which use #[aead(crate = "::vitaminc_aead")], the error names a path that does not resolve there.
Fix: build the path from the attribute, or name the limit without a crate path ("more than MAX_DEPTH levels").
There was a problem hiding this comment.
Fixed in 59b2128. The message is now built from the crate path that the rest of the expansion uses:
- default: "
TooDeepnests deeper thanstack_encrypt::plaintext::depth::MAX_DEPTHlevels. …" - with
crate = "::vitaminc_aead": "TooDeepnests deeper thanvitaminc_aead::plaintext::depth::MAX_DEPTHlevels. …"
vitaminc_aead::plaintext::depth now re-exports MAX_DEPTH, so the second path resolves. A new expansion test failed against the old fixed string and passes now.
| let tables = tables(); | ||
| let dependencies = tables | ||
| .iter() | ||
| .find(|(name, _)| name == "dependencies") |
There was a problem hiding this comment.
Nit: the guard reads only the table named exactly [dependencies].
A dependency added as [dependencies.serde], under [target.'cfg(unix)'.dependencies], or under [build-dependencies] is never compared, and the_only_dependency_is_stack_encrypt still passes. The crate would then no longer prove what its docs say.
Fix: treat every dependency table as a dependency table (any table whose name is, or ends in, dependencies, except dev-dependencies), and fail when one lists anything but stack-encrypt. Add a test case for each form.
There was a problem hiding this comment.
Fixed in 0f566a1. The guard now parses the manifest with the toml crate, which trybuild already brings into the lockfile. It reads every dependency table: [dependencies], [build-dependencies] and [dev-dependencies], at the top level and under every [target.<cfg>], including sub-tables and dotted keys. Only a dev-dependency table may list anything but stack-encrypt, and no table may name a vitaminc crate, renamed or not.
13 new unit tests cover each form, so the guard itself is tested.
| @@ -0,0 +1,12 @@ | |||
| //! What a user of `stack-encrypt` reads when a derive is refused. The | |||
| //! errors name `stack_encrypt` paths, since this crate has no other | |||
| //! dependency. Re-record with `TRYBUILD=overwrite cargo test -p | |||
There was a problem hiding this comment.
Nit: the snapshot can match only one feature set, and the re-record command picks the wrong one.
field_type_not_encryptable.stderr records rustc's list of FromScalar implementors, which changes with features. CI runs cargo nextest run --workspace --all-features, and feature unification adds implementors such as Decimal. The command in this comment re-records without --all-features. stack-encrypt's own tests/ui.rs warns about this and limits its test with required-features.
Fix: record and run under --all-features only (a required-features entry, and the flag in this comment), or choose a refused type whose error lists no implementors.
There was a problem hiding this comment.
Checked, and the snapshot already matches every feature set. trybuild builds the compile cases as a separate project, with only this crate's own features and dev-dependencies. Workspace feature unification does not reach it, and this crate has no features. The test passes with and without --all-features, and with CI's --workspace --all-features.
The suggested required-features pattern made it worse: adding a feature to this crate changed the implementor list under --all-features. So a685a32 instead explains this in tests/ui.rs and Cargo.toml, and adds a manifest test, the_crate_has_no_features, that keeps the condition this depends on.
The code that writes every derived `Encrypt` and `Decrypt` impl moved from vitaminc-aead-derive to stack-encrypt-derive. The supply-chain checks left the new crate out, so a change to it, or a bump of its syn, was no longer vetted. The workflow also did not start when the derive changed. The derive's dev-dependencies include stack-encrypt, and stack-encrypt reaches the rest of the workspace. So each tool now leaves out those dev-dependencies alone, and keeps the derive's normal dependencies: - cargo deny checks the derive as the root of its own graph, with `--exclude-dev`. The other two crates' checks leave the derive out with `--exclude`. A `[graph] exclude` entry cannot do this, because cargo deny cannot use an excluded crate as a root. - cargo vet keeps the derive and stack-encrypt-jsonpath in the filter. The derive's policy is `safe-to-deploy`, with `dev-criteria = []`. - stack-encrypt-jsonpath's policy asks nothing of miette. miette comes only with the `diagnostics` feature. The derive does not turn it on. The derive's graph brings in thiserror 1.0.69 and thiserror-impl 1.0.69, through stack-encrypt-jsonpath. No imported registry audits them, so they are exemptions at `safe-to-deploy`, as thiserror 2.0.18 is. The reviewer decides whether an audit should replace them. The licence check allows the PolyForm Small Business licence for the two first-party crates only.
The too-deep compile error named `stack_encrypt::plaintext::depth::MAX_DEPTH` as fixed text. Every other path in the expansion follows `#[aead(crate = "...")]`. A type derived with `crate = "::vitaminc_aead"`, as vitaminc-aead's tests and docs do, was told about a path that does not resolve there. The message now builds the path from the crate path. vitaminc-aead re-exports `MAX_DEPTH` from `plaintext::depth`, as stack-encrypt does, so the path resolves under both crates. An expansion test checks the message for the default path and for `::vitaminc_aead`. vitaminc-aead's `sink_too_deep` snapshot now names `vitaminc_aead::plaintext::depth::MAX_DEPTH`.
The manifest guard compared only the table named `[dependencies]`. A dependency written as `[dependencies.serde]`, or listed under `[target.'cfg(unix)'.dependencies]` or `[build-dependencies]`, was never read. The guard still passed, and the crate no longer showed what its docs say. The guard now parses the manifest with the `toml` crate, as a new dev-dependency. trybuild already brings `toml` 1.1.8 into the lockfile. Parsing reads every form Cargo accepts, including dotted keys under a target. A table other than a dev-dependency table can list only stack-encrypt, at the top level or under a target. No table names a vitaminc crate, under its own name or through `package`. Unit tests feed the checks a manifest for each form.
…ture set rustc lists a trait's other implementors in the errors that `field_type_not_encryptable.stderr` records. A stack-encrypt feature such as `dynamic` adds implementors. So the recording looked as if it could match only one feature set, and as if the re-record command picked the wrong one. It matches every feature set. trybuild builds the ui cases as a separate project, from this crate's dev-dependencies and features. This crate has no features, so CI's `--workspace --all-features` run records the same errors as a plain `cargo test`. Both pass with the committed recording. Limiting the test with `required-features`, as stack-encrypt's own ui test does, would need a feature here that turns on `stack-encrypt/dynamic`. That feature would add `&Frame<'_>` and `&Lent<'_, T>` to the lists, and so make the recording depend on features after all. The ui test's docs now say why the recording matches every feature set. A manifest test fails if a `[features]` table is added to this crate.
The comment above the two licence exceptions said the crates are under a PolyForm Small Business licence. Their LICENSE file is the PolyForm Internal Use License. cargo-deny reads that text as PolyForm-Small-Business-1.0.0, so the exception has to name that identifier. The comment now says so.
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 6e5cda5 · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review agent · claude-opus-5-5; rust-security agent · claude-opus-5-5
Skills: code-review, mattpocock-skills:code-review, company-skills:rust-security, company-skills:review-cross-check
Findings (5): 2 major, 3 minor — 3 inline, 1 below, 1 in reply.
-
AGENTS.md:817(outside diff) minor Two sentences still say there are three AEAD crates:AGENTS.md:817-818("for the three AEAD crateskani.yml, …") andAGENTS.md:878("All three#[deny(unsafe_code)]"), and so does the rootCargo.toml:5comment. Onlyvitaminc-aeadandrecipher-frameremain, so change "three" to "two" at all three sites.Source: mattpocock-skills:code-review agent · claude-opus-5-5
Generated by Claude Code
| @@ -769,7 +768,7 @@ reaches a published crate only once the copies are published from here, | |||
| which the plan schedules before the next `stack-encrypt` release. | |||
|
|
|||
| - **Three Cargo workspaces, not one.** The root workspace (the seven stack-* | |||
There was a problem hiding this comment.
major This PR adds packages/stack-encrypt-downstream to the root workspace members (Cargo.toml:17), so there are now eight stack-* crates, not seven. The Repository Layout bullet at line 93 also leaves it out of its opening path list and still says "and one added here". Change "seven" to "eight" here, and add the crate to line 93's list with "two added here".
Source: mattpocock-skills:code-review agent · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in d2274a9. The Repository Layout bullet lists packages/stack-encrypt-downstream and says "two added here", and "Working on the Rust crates" says eight stack-* crates. SECURITY.md now says the crate is an unpublished test crate, as it does for eql-encryption-tests.
| @@ -20,7 +20,6 @@ on: | |||
| - packages/stack-guest-abi/** | |||
There was a problem hiding this comment.
minor packages/stack-encrypt-downstream/** is missing from both path lists (the pull_request list here and the push list at line 42), though tests-crates.yml lists it. A PR that changes only packages/stack-encrypt-downstream/tests/manifest.rs to stop using toml leaves an unused dev-dependency, and udeps never starts. Add the path to both lists.
Source: code-review · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 4c4a3d3. packages/stack-encrypt-downstream/** is in both the pull_request and push path lists, and the two lists match. No other workflow needs it: the others list the derive because their builds depend on stack-encrypt, and nothing depends on the downstream crate.
| @@ -0,0 +1,113 @@ | |||
| //! Types of an application that depends on `stack-encrypt` and nothing | |||
There was a problem hiding this comment.
minor This crate has none of the security lint block its stack-* siblings carry (stack-encrypt/src/lib.rs:3-16), and no [lints] table covers it. A dbg!(&self.cents) or core::mem::forget in impl Encrypt for Price passes CI's clippy -D warnings, because dbg_macro and mem_forget are restriction lints. Copy the block here, with the same allows for unwrap/expect in tests/.
Source: rust-security agent · claude-opus-5-5
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 1c29cbd. The crate has the same security lint block as stack-encrypt, with the same allows for tests. I checked that it works: a dbg! and a mem::forget added for a moment both failed clippy.
stack-encrypt-downstream is a member of the root Cargo workspace, so the counts in AGENTS.md were one short. The Repository Layout bullet now lists the crate in its opening paths and says two crates were added here. The workspace note now says eight stack-* crates. SECURITY.md lists the unpublished test harness `eql-encryption-tests` and says that it adds no published package. stack-encrypt-downstream is also an unpublished test crate, so SECURITY.md now says the same of it.
The AEAD crates moved from vitaminc are now vitaminc-aead and recipher-frame. The derive crate that came with them is gone. Its code is in stack-encrypt-derive. Two sentences in AGENTS.md and the comment above the root workspace members still counted three. The AGENTS.md sentence about `#![deny(unsafe_code)]` is still true of both crates.
cargo udeps runs over the whole root workspace, and stack-encrypt-downstream is a member. But neither path list named the crate. A change that stops using one of its dev-dependencies, such as `toml`, did not start the job. Both lists now name it, as tests-crates.yml does. The other workflows that list stack-encrypt-derive do so because their builds depend on stack-encrypt, or because they check named crates. Nothing depends on stack-encrypt-downstream, so they do not list it.
The other stack-* crates warn on `dbg!`, `mem::forget`, printing, `unwrap`, `expect`, and `panic!`. Those crates also deny unsafe code. CI's clippy turns each warning into an error. The downstream crate had none of these lints. Clippy does not run most of them by default, because they are restriction lints. So a `dbg!(&self.cents)` in the hand-written `Encrypt` for `Price` passed CI. The crate now carries the same block as stack-encrypt, with the same allowances for unit tests. Nothing in the crate breaks the lints.
The CHANGELOG said that `#[aead(crate = "...")]` still works with a path to `vitaminc_aead`. The derives' code names `<crate>::__derive`. Only the `vitaminc-aead` source in this repository has that module. crates.io's 0.10.0 does not. So the line was true only inside this repository, and the CHANGELOG now says so. The entry for the too-deep error also says that its path starts at the `crate` path, when a type names one.
|
The finding outside the diff is fixed in afdfcff. |
Brings in #2014 and, through it, next with #2011. Conflicts: - stack-encrypt's lib.rs: this branch re-exports `FromScalar` and `Scalar`, and #2011 re-exports `ScalarTarget`. The merge re-exports all three. - stack-encrypt's CHANGELOG: both sides added an entry at the top of Added. The merge keeps both entries. - owned_collection_elements.stderr: the merge takes the snapshot of #2014. Recording it again with TRYBUILD=overwrite gave the same file. #2011 added tests and a doc example to vitaminc-aead that use the derives from vitaminc_aead. On this branch vitaminc-aead has no derives. So these now use stack_encrypt_derive with `#[aead(crate = "::vitaminc_aead")]`, as the other vitaminc-aead tests do: - tests/scalar_target.rs - four compile-fail tests in tests/ui/scalar_target/ - the example on `ScalarTarget` in typed.rs The four snapshots of those compile-fail tests change only in their line numbers. Two doc comments in typed.rs now say "Stack Encrypt's `#[derive(Decrypt)]`", as the rest of the file does.
The merge of #2014 added packages/mn-meta.err and packages/eql/tests/timing/mn-meta.err. Both are empty logs from a local lockfile check, and are not part of the change.
Summary
#[derive(Encrypt)]and#[derive(Decrypt)]are now Stack Encrypt's own derives. A crate whose only dependency isstack-encryptcan derive both traits, or write them by hand. Before this PR, the user'sCargo.tomlalso neededvitaminc-aead, and the compile error did not say so.The
vitaminc-aead-derivecrate is deleted.vitaminc-aeadkeeps the traits and has no derives of its own.Closes #2013. This PR is stacked on #2014. Both change the same derive code.
What a user writes
Before:
After,
stack-encryptalone. The derive code is the same:A hand-written impl imports from
stack_encrypt:Changes
The derive code moved into
stack-encrypt-derive. Its source, unit tests, and attribute docs moved withgit mv, so they keep their history. There is one place to fix a derive bug, and one set of expansion tests.Generated code names
stack_encrypt. It writes::stack_encrypt::__derive::X.__deriveis a hidden module that lists only the 23 items the generated code uses.#[aead(crate = "...")]still overrides the path, for crates in this repository that cannot namestack_encrypt.New public paths for a hand-written impl:
ScalarandFromScalar, besideEncrypt,EncryptRef,Decrypt, andDecodeError;stack_encrypt::plaintextmodule:Sink,SeqSink,MapSink, and the type descriptions such asFixedType;stack_encrypt::plaintext::depth:SCALAR,MAX_DEPTH, and the other depth helpers.The whole
vitaminc_aeadcrate is not re-exported.Compile errors name Stack Encrypt paths, such as
stack_encrypt::plaintext::depth::MAX_DEPTH.A crate that proves it:
packages/stack-encrypt-downstream. It is a workspace member that CI builds, withpublish = false. Its only dependency isstack-encrypt.Encrypt,Scalar, andFromScalarby hand for one more type.keyset.encryptandencrypt_tree.tests/manifest.rsfails if the crate lists any dependency butstack-encrypt, or names a vitaminc crate.vitaminc-aead's own derive tests stay where they are. They usestack-encrypt-deriveas a dev-dependency, with#[aead(crate = "::vitaminc_aead")]. So mutation testing ofvitaminc-aeadstill runs them.Every other Cargo workspace drops its patch entry for the deleted crate. None of them used the derives. They are:
Docs and config: CHANGELOGs,
AGENTS.md,SECURITY.md,CODEOWNERS,release-plz.toml, the mutation-testing config, and the path filters of ten workflows.Breaking changes
#[derive(vitaminc_aead::Encrypt)], or importing the derive macros fromvitaminc_aead, no longer compiles. Import them fromstack_encrypt.#[aead(crate = "...")]now names the path tostack_encrypt. A path tovitaminc_aeadstill works, because that crate has the same hidden module.Verification
Run locally on Rust 1.94.1.
Root workspace:
-D warningsfor all features and forstack-encryptwith no default featuresstack-encrypt-derive,vitaminc-aead(all features),stack-encrypt(all features, with the compile tests),stack-encrypt-downstreamandrecipher-framevitaminc-aeadtests with no features, and with each ofjiff,rust_decimal,uuid, andhlistRustdoc: public and private items, with
-D warnings, for the changed crates.Mutation testing (
--in-diff): 17 mutants, 14 caught, 3 that do not compile, 0 missed.Supply chain:
cargo vet --locked, andcargo denyforvitaminc-aeadandrecipher-frame.Lockfiles:
cargo metadata --lockedpasses in all 10 workspaces whose lockfile changed.Other workspaces:
eql-bindingswith all features, and the encryption testsThese ran before the merge of fix(stack-encrypt): encrypt a derived newtype with keyset.encrypt #2014's latest commits. Those commits changed only messages and docs.
Test counts: no test was removed. The 93 derive unit tests are the old crate's 61 plus 32. The derive doctests went from 43 to 29, because the old crate included its attribute docs three times; the 8 distinct examples each run once.
Not run: the nightly fuzz builds, the release-only jiff test, and the script tests, because the worktree has no
node_modules.Related
stack-encrypt/CHANGELOG.md,stack-encrypt/src/lib.rs, and the snapshotowned_collection_elements.stderr). Six files in feat(stack-encrypt)!: encrypt and decrypt one value known only at run time, and bound the typed decrypt to a scalar #2011 also import the derives fromvitaminc_aeadand need the same change as this PR.TakesScalarthen goes instack_encrypt::plaintext.Review notes
Open questions:
stack-encryptdepends onvitaminc-aeadfrom crates.io, sovitaminc-aeadmust be published from this repository first. Removing its derive macros is a breaking change. 0.11.0 is the semver-correct version, but the vitaminc crates that depend on it would need new releases too.src/value/LICENSE-MIT. The crate itself is licensed PolyForm Internal Use. In git, the only authors of these files are CipherStash staff and release bots, so they could be relicensed.#[aead(...)]. It does not name vitaminc. It also keeps these attributes apart from the record derives'#[stash(...)]: both have apassthroughkey with a different meaning.vitaminc_aeadin the dependency graph". It comes fromvitaminc-aead0.5.1. That version is a dependency ofcts-common. This PR does not cause it.